package tma.android.gtasks;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends FragmentActivity {

	ViewPageAdapter viewPageAdapter;

	ViewPager mViewPager;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		viewPageAdapter = new ViewPageAdapter(
				getSupportFragmentManager());

		// Set up the ViewPager with the sections adapter.
		mViewPager = (ViewPager) findViewById(R.id.pager);
		mViewPager.setAdapter(viewPageAdapter);
		
		

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	public class ViewPageAdapter extends FragmentPagerAdapter {

		public ViewPageAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public int getCount() {
			return 2;
		}

		@Override
		public Fragment getItem(int number) {
			switch (number) {
			case 0:
				return new TaskListFragment();
			case 1:
				return new CalendarFragment();
			default:
				return new TaskListFragment();
			}
		}
		
		@Override
		public CharSequence getPageTitle(int position) {
			switch (position) {
			case 0:
				return getString(R.string.title_section_tasklist).toUpperCase();
			case 1:
				return getString(R.string.title_section_calendar).toUpperCase();
			}
			return null;
		}
	}
	
	public void moveToSetting(View view) {
		Intent intent = new Intent(this, SettingActivity.class);
		startActivity(intent);
	}
	
	public void moveToAdd(View view){
		Intent intent = new Intent(this,Add_task.class);
		startActivity(intent);
	}
	
	
}
